﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace aaaa
{
    public partial class BJUD : Form
    {
        public BJUD()
        {
            InitializeComponent();
        }

        private void BJUD_Load(object sender, EventArgs e)
        {
            string sql = "select bjname from classtest";
            SqlOperate onj = new SqlOperate();
            SqlDataReader read = onj.getDataReader(sql);
            while (read.Read())
            {
                comboBox1.Items.Add(read.GetValue(0).ToString());
            }
            comboBox1.SelectedIndex = 0;


            string sql1 = "Select * from classtest ";
            SqlOperate obj = new SqlOperate();

            obj.getDataBind(dataGridView1, sql1);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = "";
            if (comboBox2.Text == "班级主任：")
            {
                str="bjteacher";
            }
            else if (comboBox2.Text == "班级电话：")
            {
                str = "bjcallnum";
            }
            else if (comboBox2.Text == "所属专业:")
            {
                str = "zyname";
            }
            else if (comboBox2.Text == "所属系部:")
            {
                str = "xbname";
            }
            else if (comboBox2.Text == "班级名称：")
            {
                str = "bjname";
            }
            string sql = "update classtest set  "+str+" = '"+textBox1.Text+"' where bjname ='"+comboBox1.Text+"'";
            SqlOperate obj = new SqlOperate();
            int i = obj.getIUD(sql);
            if (i > 0)
            { MessageBox.Show("修订记录成功！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            string sql1 = "Select * from classtest ";
            SqlOperate obj1 = new SqlOperate();

            obj1.getDataBind(dataGridView1, sql1);
            }
            else
            { MessageBox.Show("修订记录失败！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
